package Q383

class Main {

}

class Solution {
    fun canConstruct(ransomNote: String, magazine: String): Boolean {
        val charsRan: CharArray = ransomNote.toCharArray()
        val charsMa: CharArray = magazine.toCharArray()

        var res = IntArray(26)

        for (c in charsMa) {
            res[c - 'a']++
        }

        for (c in charsRan) {
            when {
                res[c - 'a'] > 0 -> res[c - 'a']--
                else -> return false
            }
        }
        return true
    }
}

fun main() {

}